"""
配置app   数据库mysql和redis
开发环境下的和生产环境下的
映射开发生产关系

"""
import logging

import redis
from flask import session


class Config(object):
    SECRET_KEY = "#*$&%(*#%&(*#%&(%*#"

    # 对数据库进行配置
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/info_gz08"
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # 对redis进行配置
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379

    # 对session进行配置
    SESSION_TYPE = "redis"  # 存储类型
    SESSION_USE_SIGNER = True  # 签名存储
    SESSION_KEY_PREFIX = "Session:"  # 键的前缀
    SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT)  # 制定存储位置
    PERMANENT_SESSION_LIFETIME = 3600 * 24 * 2  # 设置session两天有效


class DevelopmentConfig(Config):
    DEBUG = True
    LOG_LV = logging.DEBUG


class ProductionConfig(Config):
    DEBUG = False
    LOG_LV = logging.ERROR


config_dict = {
    "develop": DevelopmentConfig,
    "product": ProductionConfig
}
